<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计数器</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
</head>
<body>
    <div id="app">
        <h1>计数器</h1>
        <p>数值：{{a}}</p>
        <button @click="add">增加</button>
        <button @click="sub">减少</button>
    </div>

    <script>
        const app = Vue.createApp({
            data() {
                return {
                    a:0
                }
            },
            methods: {
                add(){
                    this.a++
                    console.log("增加被点击")
                },
                sub(){
                    this.a--
                    console.log("减少被点击")
                }
            }
        })
        app.mount("#app")
    </script>
</body>
</html>